<?php
	include('modele_Connexion.php');
	
	if (isset($_POST['do'])){
		if($_POST['do'] == "modifierNews"){
		
		$req = $bdd->prepare('UPDATE news SET contenuNews = :contenu, titreNews = :titre WHERE idNews = :id');
			$req->execute(array(
				'contenu' => $_POST['contenuNews'],
				'titre' => $_POST['titre'],
				'id' => $_POST['idNews']
				));
			
			header('Location:index.php?page=Admin');
		}
		else if($_POST['do'] == "ajouterNews"){
			
			$date = date("Y/m/d  H:i:s", time());
			$req = $bdd->prepare('INSERT INTO news(titreNews, dateNews, contenuNews) VALUES(:titre, :date, :contenu)');
			$req->execute(array(
				'titre' => $_POST['titre'],
				'date' => $date,
				'contenu' => $_POST['contenuNews']
			));
			
			include("addRSSArticle.php");
			
			header('Location:index.php?page=index.php?page=news&p=1');
		}
		else if($_POST['do'] == "supprimerNews"){
		
			$req = $bdd->prepare('DELETE FROM news WHERE idNews = :id');
			$req->execute(array(
				'id' => $_POST['idNews']
				));

			header('Location:index.php?page=Admin');
		}
		else if($_POST['do'] == "supprimerCommentaire"){
		
			$req = $bdd->prepare('DELETE FROM commentaires WHERE idComm = :id');
			$req->execute(array(
				'id' => $_POST['idComm']
				));
				
			header('Location: index.php?page=livre_d_or&p=1');
		}
	}